import { useRequest } from 'ahooks';
import { getQuestionList } from '../services/question';
import { useSearchParams } from 'react-router-dom';
type OptionType = {
    isStar: boolean;
    isDelete: boolean;
};
export default function useLoadQuestionListData(opt: Partial<OptionType>) {
    const { isStar, isDelete } = opt;
    const [searchParams] = useSearchParams();
    async function load() {
        const keyword = searchParams.get('keyword') || '';
        const data = await getQuestionList({ keyword, isStar, isDelete });
        return data;
    }
    const { data, loading, error } = useRequest(load, {
        refreshDeps: [searchParams], // 刷新依赖项
    });
    return { data, loading };
}
